#https://zhuanlan.zhihu.com/p/61628249

graph = {
        'a' : ['b', 'c'],
        'b' : ['a', 'c'],
        'c' : ['a','d'],
        'd' : ['c'],
        }

def BFS(graph, start_point):
    seen = set()
    queue = []
    queue.append(start_point)
    while len(queue)>0:
        vertex = queue.pop()
        nodes = graph[vertex]
        seen.add(vertex)
        for node in nodes:
            if node not in seen:
                queue.append(node)
        print(seen)    
    return seen

def DFS(graph,start_point):
    seen = set()
    queue = []
    queue.append(start_point)
    while len(queue)>0:
        vertex = queue.pop()
        nodes = graph[vertex] 
        for node in nodes:
            if node not in seen:
                queue.append(node)
                seen.add(node)
        print(seen)    
    return seen

seen = DFS(graph, 'a')
print(seen)
pass